# coding:UTF-8
# ________________________
# Project_Name:pyzidonghua
# File_Name:Administrator
# Author:Administrator
# Date_Time:2022/5/17 9:34
# Description:
# ________________________
import unittest
import time
from appium import webdriver
from appium.webdriver.common.appiumby import By

class DengLu(unittest.TestCase):
    def setUp(self) -> None:
        desired_caps = {}
        desired_caps['platformName'] = 'Android'  # 系统名称
        desired_caps['platformVersion'] = '7.1.2'  # 系统的版本号
        desired_caps['deviceName'] = 'Android Emulator'  # 设备名称，这里是虚拟机，这个没有严格的规定
        desired_caps['appPackage'] = 'com.netease.cloudmusic'  # APP包名
        desired_caps['appActivity'] = 'com.netease.cloudmusic.activity.LoadingActivity'  # APP入口的activity
        desired_caps['noReset'] = True  # 不重置app的缓存文件
        desired_caps['unicodeKeyboard'] = True  # 设置键盘支持中文输入
        desired_caps['resetKeyboard'] = True  # 重置键盘

        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

    def test(self):
        time.sleep(8)
        self.driver.find_element(By.ID,"com.netease.cloudmusic:id/icon").click()
        time.sleep(30)
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/login_btn').click()#立即登录
        # time.sleep(4)
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/qq').click()#点击QQ
        # time.sleep(3)
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/positiveBtn').click()#点击同意
        # time.sleep(3)
        #
        # self.driver.find_element(By.ID,'com.tencent.mobileqq:id/fds').click()#点击授权登录
        # time.sleep(3)
        #
        # self.driver.find_element(By.ID,'com.tencent.mobileqq:id/b7p').click()#完成授权
        # time.sleep(3)
        #
        # actual=self.driver.find_element(By.ID,"com.netease.cloudmusic:id/nickname").text
        # #断言
        # self.assertEqual('哈哈哈哈',actual)
        #
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/searchBar').click()#点击搜索
        # time.sleep(3)
        #
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/search_src_text').send_keys('此生不换')
        # time.sleep(6)
        #
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/tvSuggestKeyword').click()#选择第二个
        # time.sleep(3)
        #
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/musicListItemContainer').click()#选择出现的第一首歌
        # time.sleep(40)
        #
        # self.driver.tap([(450,1116)])#点击评论
        # time.sleep(7)
        #
        # self.driver.find_element(By.ID,'com.netease.cloudmusic:id/edit').send_keys("一直一直很喜欢的一首歌")#输入评论
        # time.sleep(4)
        #
        # self.driver.find_element(By.XPATH,"//android.widget.TextView[@text='发送']").click()#发送评论
        # time.sleep(6)


    def tearDown(self) -> None:
        self.driver.quit()